package edu.drexel.cs544.group11.common;

/**
 * Represents a response status code.
 * 
 * CS 544
 * 
 * @author Group 11:
 * @author Jason Setzer
 * @author Tam Thongsima
 * @author Kenny Oyefara
 * @author Chase Miller
 * 
 * @date Spring 2013
 * 
 */
public enum ResponseStatusCode {
    
    SUCCESS(
	    1),
    FAIL(
	    -1);
    
    private int number;
    
    ResponseStatusCode(int code) {
	this.number = code;
    }
    
    /**
     * Converts an int to this enum.
     * 
     * @param value
     * @return
     * @throws IllegalArgumentException
     */
    public static ResponseStatusCode valueOf(int value) throws IllegalArgumentException {
	//TODO - there has to be a better way to do this.
	
	ResponseStatusCode valueToReturn = null;
	switch (value) {
	    case 1:
		return ResponseStatusCode.SUCCESS;
	    case -1:
		return ResponseStatusCode.FAIL;
	    default:
		break;
	}
	
	if (valueToReturn == null) {
	    throw new IllegalArgumentException();
	}
	
	return valueToReturn;
    }
    
    /**
     * Returns the int representation of this enum.
     * 
     * @return
     */
    public int getInt() {
	return this.number;
    }
}
